<?php namespace Admin\Controller;
class TagController extends CommonController{
	private $model;
	public function __auto(){
	    $this->model=new \Common\Model\Tag;
	}
	//添加标签
	public function add(){
		if(IS_POST){
			if(!$this->model->store()){
				View::error($this->model->getError());
			}else{
				View::success('添加成功');
			}
		}
	    View::make();
	}
	//显示所有的标签
	public function index(){
		$data=$this->model->get();
		View::with('data',$data);
	    View::make();   
	}
	//编辑
	public function edit(){
		if(IS_POST){
			$tid=Q("post.tid",0,'intval');
			if($this->model->edit($tid)){
				View::success('修改成功',U('index'));
			}else{
				View::error($this->model->getError());
			}
		}
	    $tid=Q("get.tid",0,'intval');
		//获取点击的数据
		$data=$this->model->where("tid={$tid}")->find();
		View::with('data',$data);
		View::make();
	}
	//删除
	public function del(){
	    $tid=Q("get.tid",0,'intval');
		$this->model->where("tid={$tid}")->delete();
		View::success('删除成功');
	}
}
//
 ?>